/***********************************************************************************************************************************
 * Name:	xp_readerrorlog.sql
 * Author:	Frank Figearo (frank@sqlnerd.me)
 * Summary:	Template for xp_readerrorlog extended stored procedure call.
 */
SET IMPLICIT_TRANSACTIONS OFF; WHILE 0 < @@TRANCOUNT ROLLBACK;
GO
CREATE TABLE #ErrorLog (LogDate DATETIME NOT NULL, ProcessInfo SYSNAME NOT NULL, Text NVARCHAR(MAX));
INSERT INTO #ErrorLog EXECUTE master.sys.xp_readerrorlog
	0,		-- Log File: 0=Current, n=Archive(n)
	1,		-- Log Type: 1=Error, 2=Agent
	Null,	-- Search String 1
	Null,	-- Search String 2
	Null,	-- Search From Time
	Null,	-- Search To Time
	'ASC';	-- Results Order: ASC or DESC
GO